package fr.umlv.m2.jee.spij.service.schedule;

import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Bean for calendar.
 */
@Component("calendarBean")
public class CalendarBean {

    /**
     * locale.
     */
    private Locale locale;

    /**
     * tag for popup.
     */
    private boolean popup;

    /**
     * readonly tag.
     */
    private boolean readonly;

    /**
     * showInput tag.
     */
    private boolean showInput;

    /**
     * enableManualInput tag.
     */
    private boolean enableManualInput;

    /**
     * current date.
     */
    private Date currentDate;

    /**
     * selected date.
     */
    private Date selectedDate;


    /**
     * joint point.
     */
    private String jointPoint;

    /**
     * direction.
     */
    private String direction;

    /**
     * boundary.
     */
    private String boundary;

    /**
     * tag for label.
     */
    private boolean useCustomDayLabels;

    /**
     * @return the locale bean.
     */
    public final Locale getLocale() {
        return locale;
    }

    /**
     * @param newLocale the new locale to set.
     */
    public final void setLocale(final Locale newLocale) {
        this.locale = newLocale;
    }

    /**
     * @return informs if the calendar has popup.
     */
    public final boolean isPopup() {
        return popup;
    }

    /**
     * @param newPopup the new popup tag to set.
     */
    public final void setPopup(final boolean newPopup) {
        this.popup = newPopup;
    }

    /**
     * Empty constructor.
     */
    public CalendarBean() {
        locale = Locale.FRANCE;
        popup = false;
        jointPoint = "bottomleft";
        direction = "bottomright";
        readonly = true;
        enableManualInput = false;
        showInput = true;
        boundary = "inactive";
        currentDate = new Date();
        selectedDate = new Date();
    }

    /**
     * @return informs if the calendar has input.
     */
    public final boolean isShowInput() {
        return showInput;
    }

    /**
     * @param newShowInput the new showInput to set.
     */
    public final void setShowInput(final boolean newShowInput) {
        this.showInput = newShowInput;
    }

    /**
     * @return informs if the calendar is enable to manual input.
     */
    public final boolean isEnableManualInput() {
        return enableManualInput;
    }

    /**
     * @param newEnableManualInput the new value to set.
     */
    public final void setEnableManualInput(final boolean newEnableManualInput) {
        this.enableManualInput = newEnableManualInput;
    }

    /**
     * @return informs if the calendar is in read only mode.
     */
    public final boolean isReadonly() {
        return readonly;
    }

    /**
     * @param newReadonly the new value to set.
     */
    public final void setReadonly(final boolean newReadonly) {
        this.readonly = newReadonly;
    }

    /**
     * @return informs if the calendar use custom day label.
     */
    public final boolean isUseCustomDayLabels() {
        return useCustomDayLabels;
    }

    /**
     * @param newUseCustomDayLabels the new tag to set.
     */
    public final void setUseCustomDayLabels(
            final boolean newUseCustomDayLabels) {
        this.useCustomDayLabels = newUseCustomDayLabels;
    }

    /**
     * @return the current date as string.
     */
    public final String getCurrentDateAsText() {
        return DateFormat.getDateInstance(DateFormat.FULL).format(
                getCurrentDate());
    }

    /**
     * @return the current date.
     */
    public final Date getCurrentDate() {
        return new Date(currentDate.getTime());
    }

    /**
     * @param newCurrentDate the new date to set.
     */
    public final void setCurrentDate(final Date newCurrentDate) {
        this.currentDate = new Date(newCurrentDate.getTime());
    }

    /**
     * @return the selected date.
     */
    public final Date getSelectedDate() {
        return new Date(selectedDate.getTime());
    }

    /**
     * @param newSelectedDate the new date to set.
     */
    public final void setSelectedDate(final Date newSelectedDate) {
        this.selectedDate = new Date(newSelectedDate.getTime());
    }

    /**
     * @return the joint point.
     */
    public final String getJointPoint() {
        return jointPoint;
    }

    /**
     * @param newJointPoint the new value to set.
     */
    public final void setJointPoint(final String newJointPoint) {
        this.jointPoint = newJointPoint;
    }

    /**
     * @return the direction.
     */
    public final String getDirection() {
        return direction;
    }

    /**
     * @param newDirection the new direction to set.
     */
    public final void setDirection(final String newDirection) {
        this.direction = newDirection;
    }

    /**
     * @return the boundary
     */
    public final String getBoundary() {
        return boundary;
    }

    /**
     * @param newBoundary the boundary to set.
     */
    public final void setBoundary(final String newBoundary) {
        this.boundary = newBoundary;
    }
}

